package com.runnor.common.websys.system.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.runnor.common.websys.system.config.MybatisRedisCache;
import com.runnor.common.websys.system.entity.Article;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.runnor.common.websys.system.entity.bo.ArticleBo;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author runnor
 * @description 针对表【article】的数据库操作Mapper
 * @createDate 2023-08-21 09:46:26
 * @Entity com.runnor.common.websys.system.entity.Article
 */
@Mapper
@CacheNamespace(implementation = MybatisRedisCache.class, eviction = MybatisRedisCache.class)
public interface ArticleMapper extends BaseMapper<Article> {

    Page pages(Page page, @Param(Constants.WRAPPER) QueryWrapper queryWrapper);

    @Select("SELECT DISTINCT account_name FROM `v_article` WHERE account_name LIKE CONCAT('%',#{accountName},'%')")
    List<ArticleBo> getListByAccount(@Param("accountName") String accountName);

    @Select("SELECT DISTINCT source FROM `article` WHERE source IS NOT NULL AND source LIKE CONCAT('%',#{source},'%')")
    List<ArticleBo> getListBySource(@Param("source") String source);
}




